$(function () {
    /*供货商所有单据*/
    $('#firstDate').datetimepicker({
        //viewMode: 'day',
        format: 'YYYY-MM-DD'
    });
    $('#secondDate').datetimepicker({
        format: 'YYYY-MM-DD',
        useCurrent: false //Important! See issue #1075
    });
    $("#firstDate").on("dp.change", function (e) {
        $('#secondDate').data("DateTimePicker").minDate(e.date);
    });
    $("#secondDate").on("dp.change", function (e) {
        $('#firstDate').data("DateTimePicker").maxDate(e.date);
    });

    /*供货商供货情况*/
    $('#firstDate1').datetimepicker({
        //viewMode: 'day',
        format: 'YYYY-MM-DD'
    });
    $('#secondDate1').datetimepicker({
        format: 'YYYY-MM-DD',
        useCurrent: false //Important! See issue #1075
    });
    $("#firstDate1").on("dp.change", function (e) {
        $('#secondDate1').data("DateTimePicker").minDate(e.date);
    });
    $("#secondDate1").on("dp.change", function (e) {
        $('#firstDate1').data("DateTimePicker").maxDate(e.date);
    });


    $('#table').bootstrapTable({
        url: '${pageContext.request.contextPath}/../../j/query2',
        columns: [

            {
                field: 'order',
                title: '订单号'
            }, {
                field: 'supplier.name',
                title: '供货商名称'
            },{
                field: 'date',
                title: '订单时间'
            },  {
                field: 'ietype.type',
                title: '类型'
            },  {
                field: 'money',
                title: '金额'
            },{
                field: 'staff.name',
                title: '经办人'
            }],




        method:'post',
        contentType:"application/x-www-form-urlencoded",

        queryParamsType:'',
        detailView:true,
        queryParams:function(params){
            var temp = {  //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                'pageSize': params.pageSize,  //页面大小
                'pageNumber': params.pageNumber, //页码
                'firstDate':$("#firstDate").val(),
                'secondDate':$("#secondDate").val(),
                'supplierr':$("#supplierr").combogrid('getValue')

            };
            return temp;
        },
        height:600,
        pageList:[10,20],
        pageNumber:1,
        pageSize:10,
        pagination:true,
        sidePagination:'server',



        //当点击详细图标展开详细页面的时候触发。
        onExpandRow: function (index, row, $detail) {
            var table = $detail.html("<table></table>").find("table") ;
            table.bootstrapTable({
                url: '${pageContext.request.contextPath}/../../Qbb/QqueryByOrder?order1='+row.order+'',
                columns: [{
                    field: 'number',
                    title: '货品编号'
                },{
                    field: 'name',
                    title: '货品名称'
                },{
                    field: 'comptype.name',
                    title: '单位'
                },{
                    field: 'money',
                    title: '单价'
                },{
                    field: 'num',
                    title: '数量'
                },{
                    field: 'specid',
                    title: '规格'
                },{
                    field: 'colortype.name',
                    title: '颜色'
                },
                    {
                        field:'xx',
                        title:'总金额',
                        formatter: function (value, row, index) {
                            var jia = row.money * row.num;

                            return jia;
                        }
                    }],



            }) ;
        }

    });

    $('#syso').bootstrapTable({
        url: '${pageContext.request.contextPath}/../../Qbb/qquery',
        columns: [{
            field: 'number',
            title: '货品编号'
        },{
            field: 'name',
            title: '货品名称'
        },{
            field: 'comptype.name',
            title: '单位'
        },{
            field: 'money',
            title: '单价'
        },{
            field: 'num',
            title: '数量'
        },{
            field: 'specid',
            title: '规格'
        },{
            field: 'colortype.name',
            title: '颜色'
        },{
            field: 'date',
            title: '时间'
        },{
            field:'xx',
            title:'总金额',
            formatter: function (value, row, index) {
                var jia = row.money * row.num;

                return jia;
            }
        }],




        //method:'post',
        contentType:"application/x-www-form-urlencoded",

        queryParamsType:'',
        // detailView:true,


        queryParams: maven,
        height:600,
        pageList:[10,20],
        pageNumber:1,
        pageSize:10,
        pagination:true,
        sidePagination:'server',
    });

}) ;






/*供货商所有单据*/
function ban(){
    var opt = $("#table").bootstrapTable('getOptions') ;
    var firstDate = $("#firstDate").val() ;
    var secondDate = $("#secondDate").val() ;
    var supplierr = $('#supplierr').combogrid('getValue');


    $.post('${pageContext.request.contextPath}/../../j/query2',{'supplierr':supplierr,'pageNumber':opt.pageNumber,'pageSize':opt.pageSize,'firstDate':firstDate,'secondDate':secondDate},function(data){
        //重新给table绑定数据5
        $("#table").bootstrapTable("load",data) ;
    }) ;

}

function qbyi() {
    var opt=$("#table").bootstrapTable('getOptions');

    $.post('${pageContext.request.contextPath}/../../j/Qquanbuyi',{'pageNumber':opt.pageNumber,'pageSize':opt.pageSize,},function(data){
        //重新给table绑定数据
        $("#table").bootstrapTable("load",data) ;
    }) ;
}







/*供货商供货情况*/
function tome(){
    var opt = $("#syso").bootstrapTable('getOptions') ;
    var firstDate1 = $("#firstDate1").val() ;
    var secondDate1 = $("#secondDate1").val() ;
    var supplierid = $('#t').combogrid('getValue');

    $.post('${pageContext.request.contextPath}/../../Qbb/qquery',{'supplierid':supplierid,'pageNumber':opt.pageNumber,'pageSize':opt.pageSize,'firstDate1':firstDate1,'secondDate1':secondDate1},function(data){
        //重新给table绑定数据
        $("#syso").bootstrapTable("load",data) ;
    }) ;

}

function maven(params) {
    var temp = {  //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
        'pageSize': params.pageSize,  //页面大小
        'pageNumber': params.pageNumber, //页码
        'firstDate1':$("#firstDate1").val(),
        'secondDate1':$("#secondDate1").val(),
        'supplierid':$('#t').combogrid('getValue'),
    };
    return temp;
};



